import type { FormSchema } from '@/components/core/schema-form/';
import { getManageList } from '@/api/model/manage';
const fetchOptionList = async () => {
  const data = await getManageList();
  return data.map((item) => ({
    label: item.id,
    value: item.id,
  }));
};
export const deviceManageSchemas: FormSchema<API.CreateDeviceManageParams>[] = [
  // {
  //   field: 'deviceType',
  //   component: 'Input',
  //   label: '设备类型',
  //   rules: [{ required: true, type: 'string' }],
  //   colProps: {
  //     span: 12,
  //   },
  // },
  // {
  //   field: 'meterType',
  //   component: 'Input',
  //   label: '水表类型 01-NB 02-4G 03 集中器表',
  //   rules: [{ required: true, type: 'string' }],
  //   colProps: {
  //     span: 12,
  //   },
  // },
  {
    field: 'deviceNo',
    component: 'Input',
    label: '设备编号',
    rules: [{ required: true, type: 'string' }],
    colProps: {
      span: 10,
    },
  },
  {
    field: 'name',
    component: 'Input',
    label: '名 称',
    rules: [{ required: true, type: 'string' }],
    colProps: {
      span: 10,
    },
  },
  {
    field: 'modelId',
    component: 'Select',
    label: '型号',
    required: true,
    componentProps: {
      // more details see /src/components/Form/src/components/ApiSelect.vue
      request: async (values) => {
        console.log('field30 fetch', values);
        return await fetchOptionList();
      },
      onChange: (e) => {
        console.log('selected:', e);
      },
    },
    colProps: {
      span: 10,
    },
  },
  {
    field: 'description',
    component: 'InputTextArea',
    label: '描 述',
    rules: [{ required: true, type: 'string' }],
    colProps: {
      span: 20,
    },
  },
];
